<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <input type="button" value="addName" @click="addName()">
        <ul>
            <li v-for="(n,i) in names">
                <input type="checkbox" :checked>
                {{n}}
            </li>
        </ul>
        <hr>
        <input type="button" value="addName2" @click="addName2()">
        <ul>
            <li v-for="n in names">
                <input type="checkbox" :checked="n.state">
                {{n}}
            </li>
        </ul>
    </div>
    <script src="/assets/mockjs/mock-min.js"></script>
    <script type="module">
        import { createApp } from "../assets/vue3/vue.esm-browser.js";
        createApp({
            data() {
                return {
                   names: Mock.mock({
                        "names|2": [
                            "@cname"
                        ]
                    }).names,
                     names2: Mock.mock({
                        "names|2": [
                           {
                             name:"@cname",
                             state:false
                           },
                        ]
                    }).names2,
                }
            },
            methods:{
                addName(){
                    this.names.unshift(Mock.mock('@cname'))
                }
            }
        }).mount("#app");
    </script>
</body>
</html>